/*****************************************************************//**
 * \file   Import.cpp
 * \brief  Import
 *
 * \author Wyatt
 * \date   May 2023
 *********************************************************************/
#pragma once
#include "Import.h"

#include <iostream>
#include <fstream>
#include <sstream>

#include "Macro.h"
#include "CDBReader.h"

bool importCDBFile(std::string filePath, bool if3d /*= false*/)
{
	try
	{
		//FDEBUG("Begin: import Ansys CDB File. %s", filePath.c_str());
		CDBReader* reader = CDBReader::Inst();
		CDBReader::AnalysisDimention3D = if3d;
		reader->init(filePath);
		if (!reader->Scan())
		{
			//FDEBUG("Failed: Scan file %s", reader->filePath().c_str());
		}
		reader->allocMem();
		if (reader->Read())
		{
			//FDEBUG("Read CDB file Succeed.");
		}
		else
		{
			//FDEBUG("Failed: Read CDB file failed.");
		}

		reader->cleanUp();
		reader->destroy_build();
		
		return true;
	}
	catch (...)
	{
		std::cerr << "Unknown error.\n";
		return false;
	}
}
